package com.nbers.springcloud.microservice.controller;


import com.nbers.springcloud.microservice.entity.RentHouse;
import com.nbers.springcloud.microservice.entity.base.JsonResult;
import com.nbers.springcloud.microservice.service.RentHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nbers.springcloud.microservice.controller.base.BaseController;

import java.util.List;
import java.util.Map;

/**
 * @auther simon
 * @create 2020-04-16
 * @describe 租房前端控制器
 */
@RestController
@RequestMapping("/rent-house")
@Slf4j
@Api("租房服务接口")
public class RentHouseController extends BaseController {
    @Autowired
    RentHouseService rentHouseService;

    @ApiOperation("根据参数查询租房列表")
    @RequestMapping("selectByParams")
    public JsonResult selectByParams(@RequestParam Map<String, Object> params) {
        log.info("JSONIN=" + params.toString());
        JsonResult<List> jsonResult = new JsonResult<>();
        List<RentHouse> list = rentHouseService.listByMap(params);
        jsonResult.setData(list);
        log.info("JSONOUT=" + jsonResult.toString());
        return jsonResult;
    }

    @ApiOperation("根据Id查询租房实体")
    @RequestMapping("selectById")
    public JsonResult selectById(@RequestParam String id) {
        log.info("JSONIN=" + id);
        JsonResult<RentHouse> jsonResult = new JsonResult<>();
        RentHouse rentHouse = rentHouseService.getById(id);
        jsonResult.setData(rentHouse);
        log.info("JSONOUT=" + jsonResult.toString());
        return jsonResult;
    }
}

